<template>
  <el-drawer title="报名人员" size="60%" :visible.sync="drawer">
    <div style="padding: 10px">
      <avue-crud
        ref="crud"
        v-model="form"
        :data="data"
        :option="option"
        :page.sync="page"
        :search.sync="query"
        @search-change="searchChange"
        @size-change="sizeChange"
        @current-change="currentChange"
      >
        <template slot-scope="{ type, size, row }" slot="menu">
          <el-button
            icon="el-icon-check"
            :size="size"
            :type="type"
            @click="onApprove(row, '1')"
            >同意</el-button
          >
          <el-button
            icon="el-icon-close"
            :size="size"
            :type="type"
            @click="onApprove(row, '-1')"
            >不同意</el-button
          >
        </template>
      </avue-crud>
    </div>
  </el-drawer>
</template>

<script>
import avue from "@/mixins/avue.js";
import { activity_users, activity_approve } from "@/api/alumni";

export default {
  mixins: [avue],
  data() {
    return {
      drawer: false,
      activityInfo: {},
      data: [],
      option: {
        addBtn: false,
        editBtn: false,
        delBtn: false,
        // menuWidth: "100px",
        column: [
          {
            label: "姓名",
            prop: "realName",
            search: true,
          },
          {
            label: "联系方式",
            prop: "phone",
            align: "left",
          },
          {
            label: "报名时间",
            prop: "createTime",
          },
          {
            label: "状态",
            prop: "status",
            type: "radio",
            search: true,
            dicData: [
              {
                label: "待审核",
                value: "0",
              },
              {
                label: "审核通过",
                value: "1",
              },
              {
                label: "审核不通过",
                value: "-1",
              },
            ],
            value: "0",
          },
        ],
      },
    };
  },
  methods: {
    handleOpen(row) {
      this.drawer = true;
      this.activityInfo = row;
      this.rowLoad();
    },
    onApprove(row, status) {
      activity_approve({
        id: row.id,
        status: status,
      }).then((res) => {
        this.$s.suc(res);
        this.rowLoad();
      });
    },
    rowLoad() {
      this.query.id = this.activityInfo.id;
      activity_users(this.params).then((res) => {
        let result = this.$s.res(res);
        this.data = result.records;
        this.page.total = result.totalPage;
      });
    },
  },
};
</script>

<style></style>
